import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jms.web.mapper.StudentMapper;
import com.jms.web.mapper.TeaMapper;
import com.jms.web.pojo.Student;
import com.jms.web.pojo.Tea;
import com.jms.web.until.SqlSessionFactoryUntil;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class test2 {
    @Test
    public void select()
    {
        SqlSession sqlSession = SqlSessionFactoryUntil.getSqlSession(true);
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
        List<Student> students = studentMapper.selectBetween(1,26);
        students.forEach(System.out::println);
    }
    @Test
    public void selectlimit()
    {
        SqlSession sqlSession = SqlSessionFactoryUntil.getSqlSession(true);
        TeaMapper teaMapper = sqlSession.getMapper(TeaMapper.class);
        RowBounds rowBounds = new RowBounds(0,10);
        List<Tea> list = teaMapper.selectAll02(rowBounds);
        list.forEach(System.out::println);
    }
    @Test
    public void selectpage()
    {
        SqlSession sqlSession = SqlSessionFactoryUntil.getSqlSession(true);
        TeaMapper teaMapper = sqlSession.getMapper(TeaMapper.class);
        PageHelper.startPage(1,5);
        List<Tea> teas = teaMapper.selectAll();

        PageInfo<Tea> pageInfo = new PageInfo<>(teas);

        System.out.println("当前的页码值"+pageInfo.getPageNum());
        teas.forEach(System.out::println);
    }
}
